package com.demo.association.onetomany;

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "DEPTARTMENT2")
public class DepartmentDTO {

	private int id;
	private String departName;
	Collection<EmployeeDTO> employeeList = new ArrayList<EmployeeDTO>();

	public DepartmentDTO(String deptName) {
		this.departName = deptName;
	}

	public DepartmentDTO() {
		
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "DEPT_ID")
	public int getId() {
		return id;
	}

	@Column(name = "DEPT_NAME")
	public String getDepartName() {
		return departName;
	}

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "department")
	// RELATIONSHIP
	public Collection<EmployeeDTO> getEmployeeList() {
		return employeeList;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setDepartName(String departName) {
		this.departName = departName;
	}

	public void setEmployeeList(Collection<EmployeeDTO> employeeList) {
		this.employeeList = employeeList;
	}

	@Override
	public String toString() {
		return "DepartmentDTO [id=" + id + ", departName=" + departName
				+ ", employeeList=" + employeeList + "]";
	}
}
